<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box"></div>
    <script>
        let str = `<p>{{uname}}</p><p>{{sex}}</p>`
        let data = {
            uname: '文雅儿',
            sex: '女'
        }
        let reg=/{{(\w+)}}/g
        let res=str.replace(reg,function(...args){
            return data[args[1]]

        })
        document.querySelector('#box').innerHTML = res
    </script>
</body>

</html>